package com.example._03vehicle.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;
    public JsonResult(StatusCode statusCode) {
        this.state = statusCode.getState();
        this.message = statusCode.getMessage();
    }

    public JsonResult(StatusCode statusCode,Object data) {
        this.data = data;
        this.state = statusCode.getState();
        this.message =statusCode.getMessage();
    }
    public static JsonResult success(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult success() {return new JsonResult(StatusCode.OPERATION_SUCCESS);}
    public static JsonResult user_password_error() {return new JsonResult(StatusCode.USERNAME_PASSWORD_ERROR);}
    public static JsonResult exits_error() {return new JsonResult(StatusCode.USERNAME_EXISTS);}
    public static JsonResult notlogin_error() {return new JsonResult(StatusCode.NOT_LOGIN);}
    public static JsonResult  crimeNotice() {return new JsonResult(StatusCode.NON_EXISTS);}
    public static JsonResult fail() {return new JsonResult(StatusCode.OPERATION_FAIL);}
    public static JsonResult fail_nodata(Object data) {return new JsonResult(StatusCode.OPERATION_FAIL,data);}
}
